#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;
typedef long long ll;

int n, m, q;
ll mask[1010];
ll xxx;
ll U;
char s[1010], p[1010];

void print(int x)
{
	if (x < 10)
		printf("%d", x);
	else
		printf("%c", (char)((int)'A' + x - 10));
}

void solve()
{
	scanf("%d%d%d", &n, &m, &q);
	if (n == 0 && m == 0 && q == 0)
		exit(0);
	U = (1LL << n) - 1LL;
	for (int i = 0; i < m; i++)
		mask[i] = U;
	xxx = 0LL;
	while(q--)
	{
		scanf(" %s %s ", &s, &p);
		ll y = 0LL;
		for (int i = 0; i < n; i++)
			if (s[i] == '1')
				y |= (1LL << i);
		xxx ^= y;
		for (int i = 0; i < m; i++)
			if (p[i] == '0')
				mask[i] &= (xxx ^ U);
			else
				mask[i] &= xxx;
	}
	for (int i = 0; i < m; i++)
	{
		int ans = -1;
		for (int j = 0; j < n; j++)
		{
			if ((mask[i] & (1LL << j)) == 0) continue;
			if (ans == -1)
				ans = j;
			else
				ans = -2;
		}
		if (ans == -2)
			printf("?");
		else if (ans >= 0)
			print(ans);
		else
			throw;
	}
	printf("\n");
	return;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	while(true)
		solve();

	return 0;
}